// 项目总入口
package main

import (
	"krm-backend/config"
	_ "krm-backend/controllers/initcontroller" // _表示执行该文件里面的init方法
	"krm-backend/middlewares"
	"krm-backend/routers"
	"krm-backend/utils/logs"

	"github.com/gin-gonic/gin"
)

func main() {
	//1.加载程序配置
	//2.配置gin

	r := gin.Default()
	r.Use(middlewares.JwtAuth)
	logs.Info(nil, "程序启动成功")
	// //测试生成JWT token是否可用
	// ss, _ := jwtutil.GenToken("ddd")
	// fmt.Println("测试是否能生成token", ss)

	// //验证token解析函数
	// _, err := jwtutil.ParseToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRkZCIsImlzcyI6ImRhd24iLCJzdWIiOiJjaHVhbmciLCJleHAiOjE3MjM1NjY4NzUsIm5iZiI6MTcyMzU1OTY3NSwiaWF0IjoxNzIzNTU5Njc1fQ.vVbyyArMemhHRgPzQ1WO_Y63DxNT6PU6SmzrxbvfkaM")
	// if err != nil {
	// 	fmt.Println("解析失败:", err.Error())
	// } else {
	// 	fmt.Println("okkkkkkkkkkk")
	// }
	routers.RegisterRouters(r)
	r.Run(config.Port)
}
